<template>
	<view class="news">
		
		<news-item @itemClick="goDetail" :list="newslist"></news-item>

	</view>
</template>

<script>
	import newsItem from '../../components/news-item/news-item.vue'
	export default {
		data() {
			return {
				newslist: []
			}
		},
		methods: {
			async getNews () {
				const res = await this.$myRequest({
					url: '/newslist?limit=111&page=1&sort=1'
				})
				console.log(res)
				this.newslist = res.data.data.items
			},
			goDetail (id) {
				console.log(id)
				uni.navigateTo({
					url: '/pages/new-detail/new-detail?id='+id
				})
			}
		},
		// 注册组件
		components: {"news-item":newsItem},
		onLoad() {
			this.getNews()
		}
	}
</script>

<style lang="scss">
.news {

}
</style>
